package cs271.examples.recursion;

//from http://en.wikipedia.org/wiki/Tower_of_Hanoi
public class Hanoi {
	public static void move(int d, char f, char t)
	 {
	         /* move disk d from peg f to peg t */;
	        System.out.printf("moving disk %d : %c --> %c\n", d, f, t);
	 }
	 
	 public static void hanoi(int h, char f, char t, char r)
	 {
	         if (h > 0)
	         { 
	              hanoi(h-1, f, r, t);
	              move (h-1, f, t);
	              hanoi(h-1, r, t, f);
	         }
	 }
	 
	 public static void main(String[] args) {
		 hanoi(6, 'f', 't', 'r');
	 }

}
